<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      
      body{
          perspective: 800px;  /*在设置transform:translateZ的时候要在
             把perspective写到被观察元素的父类上面
           ;*/
      }
        .aa{
            width: 200px;
            height: 200px;
            background-color: red;
            margin: 200px auto;
            transition: 2s;
        }
        /* div:hover{
            width: 300px;
            height: 300px;
            我觉得这样设置效果差不多
        } */

body:hover .aa{
 
          transform: translateZ(200px);
           /*要设置视距的时候才生效*/
}
    </style>
</head>
<body>
    <div class="aa"></div>
</body>
</html>